# 目标文件
set(BIN_TARGET ${PROJ_ROOT_DIR}/bin/${PROJECT_NAME}.bin)
set(HEX_TARGET ${PROJ_ROOT_DIR}/bin/${PROJECT_NAME}.hex)
set(MAP_TARGET ${PROJ_ROOT_DIR}/bin/${PROJECT_NAME}.map)
set(LSS_TARGET ${PROJ_ROOT_DIR}/bin/${PROJECT_NAME}.lss)

# 生成目标文件
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
        COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_TARGET}
        COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_TARGET}
        COMMAND ${CMAKE_OBJDUMP} -S $<TARGET_FILE:${PROJECT_NAME}.elf> >${LSS_TARGET}
        COMMAND ${ARM_SIZE_EXECUTABLE} -B $<TARGET_FILE:${PROJECT_NAME}.elf>
        COMMENT "Generating ${HEX_TARGET}, ${BIN_TARGET}, ${MAP_TARGET}, ${LSS_TARGET} files")